﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.Common;
// using Oracle.DataAccess.Client; // needed for Oracle Project
// using Oracle.DataAccess.Types; //needed to run stored procedures
using System.Data.OracleClient; //needed to run stored procedures

namespace prjColecao
{
    public class databaseConn
    {
        //Data Source=teiom;User ID=COLECAO;Password=OU812;Unicode=True
        //static string connectionString = "Data Source=XE;User Id=COLECAO;Password=OU812; Integrated Security = no";
        static string connectionString = "Data Source=teiom;User ID=COLECAO;Password=OU812;Unicode=True";
        protected OracleConnection sConn = new OracleConnection("Data Source=teiom;User ID=COLECAO;Password=OU812;Unicode=True");
        #region connect to database
        public void dataConnect(){
            try{
                if (sConn.State == 0){
                    sConn.Open();
                    Console.WriteLine("Conexao OK");
                }

            }catch (Exception NoConnect){
                Console.WriteLine("Conexao NAO OK");
                throw new Exception("There is no Connection" + NoConnect.Message);
            }
        }
        #endregion

        #region disconnect from database
        public void dataDisconnect(){
            try{
                sConn.Close();
            }
            catch(Exception NoConnect){
             throw new Exception("No response:" + NoConnect.Message);
            }
        }
        
        #endregion

    }
}